package mortal.game.manager
{
	import com.gengine.core.frame.*;
	import com.gengine.global.*;
	import com.gengine.utils.pools.*;
	import flash.display.*;
	import mortal.game.view.msgbroad.*;

	public class MsgBroadCastImpl extends Sprite
	{
		private var _needRedraw:Boolean;
		private var _timer:FrameTimer;
		private var _pushing:Boolean;
		private var _inDis:int = 50;
		private var _gad:int = 0;
		
		public function MsgBroadCastImpl()
		{
			mouseEnabled = false;
			mouseChildren = false;
			var sp:Sprite = new Sprite();
			sp.graphics.lineStyle(2, 16711680, 1);
			sp.graphics.beginFill(16711680, 1);
			sp.graphics.drawRect(0, 0, this.width, this.height + this._inDis);
			sp.graphics.endFill();
			addChild(sp);
			this.mask = sp;
			this._timer = new FrameTimer();
			this._timer.addListener(TimerType.ENTERFRAME, this.onEnterFrame);
			this._timer.start();
		}
		
		private function onEnterFrame(e:FrameTimer) : void
		{
			if (this._needRedraw && !this._pushing)
			{
				this._needRedraw = false;
				this.updatePxy();
			}
		}
		
		public function updatePxy() : void
		{
			var deeps:int = 0;
			var item:NoticeItem = null;
			var h:int = 0;
			var i:int = 0;
			deeps = numChildren - 1;
			while (deeps > i)
			{
				
				item = getChildAt(deeps) as NoticeItem;
				if (item.hideIng)
				{
					deeps = deeps - 1;
					continue;
				}
				if (item.disposed)
				{
					if (item.parent)
					{
						removeChild(item);
					}
					deeps = deeps - 1;
					continue;
				}
				item.x = (this.width - item.width) / 2;
				if (deeps != (numChildren - 1))
				{
					item.easeUp(this.height - item.height - h);
				}
				else
				{
					item.y = this.height - item.height - h;
				}
				h = h + item.height;
				h = h + this._gad;
				deeps = deeps - 1;
			}
		}
	}
}